package com.hkx.vo;

import  com.hkx.core.ResultCode;
import lombok.Getter;

@Getter
public class ResultVo <T>{
    private  final Integer code;
    private  final T content;
    private  final String message;

    private  ResultVo(Integer code,T content,String message){
        this.code=code;
        this.content=content;
        this.message=message;
    }
    public static <T> ResultVo<T> getInstance(ResultCode resultCode, T content, String message){
        return new ResultVo<>(resultCode.getValue(),content,message);
    }
    public static <T> ResultVo<T> success(T content,String message){
        return getInstance(ResultCode.SUCCESS,content,message);
    }
    public static <T> ResultVo<T> success(T content){
        return success(content,null);
    }
    public static <T> ResultVo<T> failed(T content,String message){
        return getInstance(ResultCode.FAILED,content,message);
    }
    public static <T> ResultVo<T> failed(String message){
        return failed(null,message);
    }
}
